﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common.Net.DesignByContract;
using ClearUnit.TestRunners.Results;
using Common.Net.DataStructures;

namespace ClearUnit.TestRunners
{
    public class TestResultCollector 
    {
        readonly List<TestRunResult> _runResults = new List<TestRunResult>();

        public TestResultCollector(ITestInfoEventNotifier notifier)
        {
            notifier.TestInfoEvent += notifier_TestInfoEvent;
        }

        void notifier_TestInfoEvent(TestRunInfo runInfo)
        {
            if (runInfo is TestRunResult)
                _runResults.Add((TestRunResult)runInfo);
        }

        public IEnumerable<MethodRunResult> MethodResults
        {
            get { return _runResults.OfType<MethodRunResult>(); }
        }

        public IEnumerable<TypeRunResult> TypeResults
        {
            get { return _runResults.OfType<TypeRunResult>(); }
        }
    }
}
